﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Tools;

namespace Pixysoft.Weblications.Sango.Formular
{
    class StrategyFormular
    {
        /// <summary>
        /// 是否战略刷新
        /// </summary>
        /// <param name="lastdate"></param>
        /// <returns></returns>
        public static bool isNextStrategyDay(double lastdate)
        {
            double refreshdate = GlobalTimer.Instance.ToTimeSequence(DateTimeCoder.Instance.GetHeadOfToday()) + PlayerFormular.default_refresh_date;

            return SettingHelper.IsDailyRefresh(refreshdate, lastdate);
        }

        /// <summary>
        /// 科技升级等级要求
        /// </summary>
        /// <param name="sys"></param>
        /// <param name="currentlevel"></param>
        /// <returns></returns>
        public static long getStrategyUpgradeBuildingLevel(Entities.Cti_Strategy sys, long currentlevel)
        {
            return (currentlevel + 1) * sys.Upgradestep;
        }

        /// <summary>
        /// 科技升级的军魂要求
        /// </summary>
        /// <param name="sys"></param>
        /// <param name="orm"></param>
        /// <returns></returns>
        public static long getStragetyUpgradeSoulvalue(Entities.Cti_Strategy sys, long strategyLevel)
        {
            //科技属性升级，1级=858军魂，增量=156军魂。

            return 858 + 156 * strategyLevel;
        }

        /// <summary>
        /// 科技升级冷却时间
        /// </summary>
        /// <param name="history"></param>
        /// <param name="cityStrategy"></param>
        /// <param name="strategyLevel"></param>
        /// <returns></returns>
        public static long getStrategyCooldownTimespan(Entities.Usr_Activity history, Entities.Cti_Strategy cityStrategy, long strategyLevel)
        {
            return DateTimeCoder.Instance.MinuteToMilliSecond((int)Math.Round(getStragetyUpgradeSoulvalue(cityStrategy, strategyLevel) / 5f));
        }
    }
}
